package main

import (
	"github.com/gin-gonic/gin"
	"gitee.com/zhucheer/prome"
	"github.com/prometheus/client_golang/prometheus"
)

func main() {

	promeIns:=prome.NewPrometheus("gin_demo").
		RegisterCustomerMetrics("customer","customer metrics", prome.CounterVec, []string{"label1","label2"})

	r := gin.Default()
	promeIns.Use(r)
	r.GET("/ping", func(c *gin.Context) {
		// 自定义指标
		metrix:=prome.PromeHandler().PromeMetrics("customer").(*prometheus.CounterVec)
		metrix.WithLabelValues("srvname1","/ping").Inc()

		// 业务报错计数指标
		prome.PromeHandler().IncGinServiceErr(c,"testSrv")

		c.JSON(200, gin.H{
			"message": "pong",
		})
	})


	r.Run(":8001")
}


